module Manage::StructuresHelper
  def edit_record_tag(record)
    path = edit_record_path(record)
    image = edit_record_image(record)
    
    content = ''
    
    unless ['#', '', nil].include?(path)
      content += link_to(image_tag(image, :alt=>t('label.edit'), :title=>t('label.edit')), path)
    end
    
    content
  end  
  
  def edit_record_path(record)
    return '#' if record.blank?
    
    case record.kind
    when :page then edit_manage_structure_page_path(:structure_id=>record.id)
    when :posts then manage_structure_posts_path(:structure_id=>record.id)
    when :gallery then manage_structure_photos_path(:structure_id=>record.id)
    when :services then manage_structure_posts_path(:structure_id=>record.id)
    when :coaches then manage_structure_posts_path(:structure_id=>record.id)
    when :sitemap, :main, :redirect, :help, :signup then '#'
    end
  end
  
  def edit_record_image(record)
    return if record.nil?
        
    case record.kind
      when :page then "manage/ico_edit.gif"
      when :posts, :main, :help, :signup, :coaches, :services, :gallery then "manage/ico_view.gif"
    end
  end
  
  def settings_record_path(record)
    return if record.nil?
    edit_manage_structure_path(:id=>record.id)
  end
  
  def structure_css_class(record)
    case record.kind
    when :page, :redirect then 'static'
    when :sitemap, :main, :posts, :help, :signup, :coaches, :services, :gallery then 'blog'
    end
  end
end
